<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('超期工单M')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="workFormNo"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-success single disabled" onclick="reply()">
                <i class="fa"></i> 回复
            </a>
            <a class="btn btn-primary single disabled" onclick="postpone()">
                <i class="fa"></i> 延期
            </a>
            <a class="btn btn-danger multiple disabled" onclick="Return()">
                <i class="fa"></i> 退回
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/common/js/common.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "system/mMailWF";
    var mInterior = ctx + "system/mInterior";
    $(function () {
        var options = {
            url: prefix + "/cmnFile/muRedSJson",
            sortName: "myPkVal",
            updateUrl: prefix + "/cmnFile/dlReplyS",
            sortOrder: "desc",
            uniqueId: "myPkVal",
            modalName: "超期工单",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            rowStyle: rowStyle,
            columns: [{
                checkbox: true
            },
                {field:'myPkVal',title:'pkid',visible:false},
                {field:'WfId',title:'WfId',visible:false},
                {field:'OriLevel',title:'OriLevel',visible:false},
                {field:'fmDept',title:'fmDept',visible:false},
                {field:'sbDept',title:'sbDept',visible:false},
                {field:'myMwfNO',title:'工单编号',align:'center'},
                {field:'SpareString',title:'信件来源',align:'center',sortable:true, formatter:function(value,row,index) {
                        return value == '互联网+督查' ? '<span style="color:red;">'+value+'</span>' : value;
                    }},
                {field:'myMwfTopic',title:'工单主题',align:'center'},
                {field:'SeqName',title:'交办次序',align:'center',sortable:true},
                {field:'SortName',title:'性质',align:'center',sortable:true},
                {field:'DealName',title:'办理方式',align:'center',sortable:true},
                {field:'bkLimit',title:'办理期限',align:'center'},
                {field:'SDeptName',title:'派发单位',align:'center',sortable:true},
                {field:'acDate',title:'签收日期',align:'center'},
                {field:'bkState',title:'审查标记',align:'center',formatter:function(value,row,index){return fmtSBBackState(value,row,index);}},
                {field:'acRemark',title:'备注',align:'center'},
                {field:'backDesc',title:'下级回复',align:'center',sortable:true,formatter:function(value,row,index){return fmtBackState(value,row,index);}},
                {field:'FlagString',title:'转办情况',align:'center',sortable:true},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="reply('+row.WfId+','+row.myPkVal+')"><i class="fa"></i>回复</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function postpone(){
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        var wfId = row[0].WfId;
        var sendId = row[0].myPkVal;
        if (wfId && sendId) {
            var url = mInterior + "/cmnFile/tDeferList?wfId="+wfId+"&sendId="+sendId;
            $.modal.openTab('延期申请情况',url);
        }
    }

    function reply(wfId,sendId){
        if (!(wfId && sendId)) {
            let row = $("#bootstrap-table").bootstrapTable('getSelections');
            var wfId = row[0].WfId;
            var sendId = row[0].myPkVal;
        }
        var url = prefix + "/cmnFile/dlReplyS?wfId="+wfId+"&sendId="+sendId;
        $.modal.openTab('回复信件工单',url);
    }

    function Return(){
        if (!(wfId && sendId)) {
            let row = $("#bootstrap-table").bootstrapTable('getSelections');
            var wfId = row[0].WfId;
            var sendId = row[0].myPkVal;
        }
        var url = prefix + "/cmnFile/dlBackS?wfId="+wfId+"&sendId="+sendId;
        $.modal.openTab('退回信件工单',url);
    }

    function fmtBackState(value,row,index) {
        var wfid = row.wfId;
        var fmunit = row.sbDept;
        var str = '';
        $.ajax({
            type: 'post',
            data: {wfId: wfid, fmunit: fmunit},
            dataType: 'json',
            async: false,
            url: ctx + '/mMailWF/forShow/updateState',
            success: function (result) {
                str = result.backDesc;
            }
        });
        return str;
    }
</script>
</body>
</html>